﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
//
using System.Collections.ObjectModel; //ObservableCollection的名空间
using System.ComponentModel;
using System.Diagnostics;//PropertyChangedEventHandler的名空间
namespace Delay
{
    public class PhoneInfoCenterView : DependencyObject, INotifyPropertyChanged
    {
        public PhoneInfoCenterView()
        {
            PoneInfoCenterItems = new ObservableCollection<PhoneInfoCenterItem>();
            //ImageVis = false;
        }
        private ObservableCollection<PhoneInfoCenterItem> _poneInfoCenterItems;
        public ObservableCollection<PhoneInfoCenterItem> PoneInfoCenterItems
        {
            get
            {
                return _poneInfoCenterItems;
            }
            set
            {
                if (_poneInfoCenterItems != value)
                {
                    _poneInfoCenterItems = value;
                    NotifyPropertyChanged("PoneInfoCenterItems");
                }
            }
        }
        private int _result;
        public int Result
        {
            get
            {
                return _result;
            }
            set
            {
                if (_result != value)
                {
                    _result = value;
                    NotifyPropertyChanged("Result");
                }
            }
        }
      
        //是否允许追加内容的开关
        public bool AllowAdd
        {
            get;
            set;
        }
        public int CurrentPage
        {
            get;
            set;
        }
        public int TotalPage
        {
            get;
            set;
        }
        public int PageSize
        {
            get;
            set;
        }
        public string ClassNmae
        {
            get;
            set;
        }
        public string GetPhoneInfoUrl(int p)
        {
            //Debug.WriteLine("class name is {0}",this);
             string url;
             if (this.ClassNmae=="more")
            {
                url = QueryXml.PhoneInfoMoreUrl;               
            }
            else
            {
                
                 url = QueryXml.PhoneInfoUrl;
                
            }
           
            url += ("imei=" + QueryXml.imei);
            url += ("&phonename=" + QueryXml.phonename);
            url += ("&phonevs=" + QueryXml.phonevs);
            url += ("&phonevsno=" + QueryXml.phonevsno);
            url += ("&keyvalue=" + QueryXml.keyvalue);
            url += ("&channelkey=" + QueryXml.channelkey);
            switch(this.ClassNmae)
            {
                case "phoneInfo":
                    url += ("&forumid=" + QueryXml.forumid_daogou);
                    break;
                case "market":
                    url += ("&forumid=" + QueryXml.forumid_hangqing);
                    break;
                case "test":
                     url += ("&forumid=" + QueryXml.forumid_ceping);
                    break;
                case "newView":
                     url += ("&forumid=" + QueryXml.forumid_xinwen);
                    break;
                case "news":
                     url += ("&forumid=" + QueryXml.forumid_xinpin);
                    break;
                case "more":
                    // url += ("&forumid=" + QueryXml.forumid_daogou);
                    break;
                default:
                    break;
            }
            if (this.ClassNmae != "more")
            {
                url += ("&p=" + p.ToString());
                url += ("&total=" + TotalPage.ToString());
                url += ("&pagesize=" + PageSize.ToString());
            }
         
            return url;
        }
        public string GetPhoneInfoUrl(int p,string  menuid)
        {
            //Debug.WriteLine("class name is {0}",this);
            string url;
           

                url = QueryXml.PhoneInfoUrl;


            url += ("imei=" + QueryXml.imei);
            url += ("&phonename=" + QueryXml.phonename);
            url += ("&phonevs=" + QueryXml.phonevs);
            url += ("&phonevsno=" + QueryXml.phonevsno);
            url += ("&keyvalue=" + QueryXml.keyvalue);
            url += ("&channelkey=" + QueryXml.channelkey);
            url += ("&forumid=" + menuid);
            url += ("&p=" + p.ToString());
            url += ("&pagesize=" + PageSize.ToString());
            url += ("&total=" + TotalPage.ToString());
            return url;
        }
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

    }
}
